package Puyo;

import javax.microedition.lcdui.*;

public class ScoreScreen extends Canvas{
  private Scores highScores;
  
  ///reset command for reset the high scores
  private Command resetCommand; 
  /**Construct the displayable*/
  public ScoreScreen() {
    highScores = new Scores();
    highScores.readScores();
    setTitle(LocalizationSupport.getMessage("SCORE_TOP_GAMERS"));
  }
  
  public void resetScores(){
    highScores.resetScores();
  }
  
  /**
   *\return true if the score is higher enough to get into the top charts.
   */
  public boolean insertHighscore( String name, int score, byte level ) {
      if(highScores.isScoreHighEnough(score)){
          highScores.insertHighscore(name, score, level);
          return true;
      }
      return false;
  }
   /** Required paint implementation */
  protected void paint(Graphics g) {
    g.setColor(0x00505094);
    g.fillRect( 0,0, getWidth(), getHeight() );
    g.setColor(0x00000000);
    highScores.draw(g, getWidth());
  }

    public Command getResetCommand() {
       if (resetCommand == null) {
           resetCommand = new Command( LocalizationSupport.getMessage("COMMAND_RESET"),
                                       Command.OK, 1);
       }
       return resetCommand;
    }

}
